home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snpd0492.zip / ABSDISKC.C < prev    next >
C/C++ Source or Header  |  1992-04-13  |  1KB  |  46 lines

  1. /*
  2. **  ABSDISKC.C - Functions to read and write absolute disk sectors
  3. **               (these will work with all versions of DOS 2-5).
  4. **
  5. **  Public domain code by Bob Stout
  6. **
  7. **  NOTE: These functions work by calling absdisk() from SNIPPETS file,
  8. **        ABSDISK.ASM.
  9. */
  10.  
  11. #include <stddef.h>
  12.  
  13. #if defined(__ZTC__)
  14.  #define GetDrive(d) dos_getdrive(&d)
  15. #elif defined(__TURBOC__)
  16.  #define GetDrive(d) ((d) = getdisk() + 1)
  17. #else /* assume MSC */
  18.  #define GetDrive(d) _dos_getdrive(&d)
  19. #endif
  20.  
  21. int absdisk(unsigned char  function,
  22.             unsigned short drive,
  23.             size_t         number_of_sectors,
  24.             size_t         starting_sector,
  25.             void *         sector_buffer);
  26.  
  27. int AbsDiskRead(unsigned short drive,
  28.                 size_t         num_of_sectors,
  29.                 size_t         sector,
  30.                 void *ptr)
  31. {
  32.       if (!drive)
  33.             GetDrive(drive);
  34.       return absdisk(0x25, drive, num_of_sectors, (unsigned)sector, ptr);
  35. }
  36.  
  37. int AbsDiskWrite(unsigned short drive,
  38.                 size_t         num_of_sectors,
  39.                 size_t         sector,
  40.                 void *ptr)
  41. {
  42.       if (!drive)
  43.             GetDrive(drive);
  44.       return absdisk(0x26, drive, num_of_sectors, (unsigned)sector, ptr);
  45. }
  46.